package com.zl.spring.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Arrays;

public class LoginDaoProxy implements InvocationHandler {

    private Object object;
    public LoginDaoProxy(Object object){
        this.object = object;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        //方法执行之前做操作
        System.out.println("方法执行之前" + method.getName() + "参数" + Arrays.toString(args));

        //被增强的方法执行
        Object res = method.invoke(object, args);

        //方法执行之后
        System.out.println("方法执行之后" + object);

        return res;
    }
}
